<?php
/**
 * 系统配置模型
 */
namespace app\msgapi\model;

use think\facade\Cache;
use think\Model;

class System extends Model
{
    protected $type = ['val'=>'serialize'];// 指定val字段为序列化类型，写入时自动序列化，取出时自动反序列化。

    public static function getSys(string $name): array
    {
        return Cache::remember('conf_'.$name, function() use ($name){
            $system = static::where('name', $name)->field('val')->findOrEmpty()->toArray();
            return (array)$system['val'];
        });
    }
}